package cn.darxs.noquestion.controller;

import cn.darxs.noquestion.entity.Question;
import cn.darxs.noquestion.mapper.QuestionMapper;
import cn.darxs.noquestion.service.QuestionService;
import net.sf.jsqlparser.Model;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/questions")
public class QuestionDisplay {
//    @Autowired
//    QuestionMapper qm;
//
//    @GetMapping
//    public String questMapper(Model m){
//        List<Question> q =  qm.findAll();
//        System.out.println(q);
//        return "q";
//    }
    @Autowired
    private QuestionService qs;

//    @GetMapping("/{id}")
//    public Question getByid(Integer id){
//        return qs.getById(id);
//    }


    @GetMapping
    public List<Question> getAll(){
        return qs.list();
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id){
//        System.out.println(id);
        return qs.delete(id);
    }

//    @PutMapping
//    public boolean update(@RequestBody Question q){
//        return qs.update(q);
//    }
//
//    @DeleteMapping("/{id}")
//    public boolean delete(@PathVariable Integer id){
//        return qs.delete(id);
//    }
//
//    @PutMapping
//    public boolean update(@RequestBody Question question){
//        return qs.update(question);
//    }
}
